import "babel-polyfill";
import React from 'react';
import { BrowserRouter as Router, Switch,Redirect,Route } from 'react-router-dom';
import { Provider } from 'mobx-react';
import { routes, RouteWithSubRoutes } from "./router";
import UserStore from './store/User'
import NoMatch from './views/dashboard/exception/404'


const App = () => {
  return (
    <Provider user={UserStore} key={'router'}>
      <Router>
        <Switch>
          {routes.map((route, i) => (<RouteWithSubRoutes key={i} {...route} />))}
          <Route path='/404' component={NoMatch} />
          <Redirect from='*' to='/404' />
        </Switch>
      </Router>
    </Provider>
  )
};
export default App